//
//  BaseViewModel.h
//  ShandongPoker
//
//  Created by Developer on 2025-01-08.
//  Copyright © 2025 ShandongPoker. All rights reserved.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

/**
 * 基础ViewModel
 * 提供通用的数据绑定和状态管理
 */
@interface BaseViewModel : NSObject

/// 是否正在加载
@property (nonatomic, assign, readonly) BOOL isLoading;

/// 错误信息
@property (nonatomic, strong, readonly, nullable) NSError *error;

/// 加载状态变化回调
@property (nonatomic, copy, nullable) void(^loadingStateDidChange)(BOOL isLoading);

/// 错误发生回调
@property (nonatomic, copy, nullable) void(^errorDidOccur)(NSError *error);

/**
 * 设置加载状态
 * @param loading 是否正在加载
 */
- (void)setLoading:(BOOL)loading;

/**
 * 设置错误信息
 * @param error 错误对象
 */
- (void)setError:(NSError * _Nullable)error;

/**
 * 清除错误信息
 */
- (void)clearError;

@end

NS_ASSUME_NONNULL_END